CREATE TABLE [dbo].[tb_AuditoriasDeSaludLaboral]
(
[IdAuditoriaDeSaludLaboral] [int] NOT NULL IDENTITY(1, 1),
[Agente] [int] NOT NULL,
[Tipo] [int] NOT NULL,
[Certificacion] [int] NULL,
[JuntaMedica] [int] NULL,
[Examen] [int] NULL,
[ZonaSaludLaboral] [int] NOT NULL,
[FechaYHora] [datetime] NOT NULL,
[Medico] [int] NOT NULL,
[Dictamen] [int] NULL,
[Diagnostico] [int] NULL,
[AvalNormativo] [int] NULL,
[Desde] [datetime] NULL,
[Hasta] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [PK_tb_AuditoriasDeSaludLaboral] PRIMARY KEY NONCLUSTERED  ([IdAuditoriaDeSaludLaboral]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] WITH NOCHECK ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_Agentes] FOREIGN KEY ([Agente]) REFERENCES [dbo].[tb_Agentes] ([idAgente])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] WITH NOCHECK ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_Licencias] FOREIGN KEY ([AvalNormativo]) REFERENCES [dbo].[tb_Licencias] ([idLicencia])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_CertificacionesMedicas] FOREIGN KEY ([Certificacion]) REFERENCES [dbo].[tb_CertificacionesMedicas] ([idCertificacion])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] WITH NOCHECK ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_Enfermedades] FOREIGN KEY ([Diagnostico]) REFERENCES [dbo].[tb_Enfermedades] ([idEnfermedad])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_DictamenDeExamen] FOREIGN KEY ([Dictamen]) REFERENCES [dbo].[tb_DictamenDeExamen] ([idDictamenExamen])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_ExamenesMedicos] FOREIGN KEY ([Examen]) REFERENCES [dbo].[tb_ExamenesMedicos] ([IdExamenMedico])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_JuntasMedicas] FOREIGN KEY ([JuntaMedica]) REFERENCES [dbo].[tb_JuntasMedicas] ([idDictamen])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_Medicos] FOREIGN KEY ([Medico]) REFERENCES [dbo].[tb_Medicos] ([idMedico])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_TipoDeAuditoria] FOREIGN KEY ([Tipo]) REFERENCES [dbo].[tb_TipoDeAuditoria] ([idTipoAuditoria])
GO
ALTER TABLE [dbo].[tb_AuditoriasDeSaludLaboral] ADD CONSTRAINT [FK_tb_AuditoriasDeSaludLaboral_tb_ZonasDeSaludLaboral] FOREIGN KEY ([ZonaSaludLaboral]) REFERENCES [dbo].[tb_ZonasDeSaludLaboral] ([idZonaSalud])
GO
